<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
  <head>
    <title>常规资费管理</title>
    <base href="<%=basePath%>">
  </head>
  
  <body>
  
  	<jsp:include page="common.jsp"></jsp:include>
  	<jsp:include page="alert.jsp"></jsp:include>
  	
  	<div class="secMenu-content">
  		<div class="list-hearBar">
	  		<a class="btn btn-primary list-headBtn" href="electric/jsp/chargesNew_cg.jsp">新增资费</a>
	  		<button type="button" class="btn btn-primary list-headBtn batch startAll" id="">批量开启</button>
	  		<button type="button" class="btn btn-primary list-headBtn batch stopAll" id="">批量暂停</button>
  			
  			<form class="form-inline list-headRight right" role="form">
				<input type="text" class="form-control" placeholder="请输入资费名称">
				
				<button type="submit" class="btn btn-info">搜索</button>
			</form>
  		</div>
  	
  	 	<table class="table table-hover table-striped table-condensed list-table">
	      <thead>
	        <tr>
	          <th><input type="checkbox" class="checkbox-length list-checkboxAll"></th>
	          <th>资费编号</th>
	          <th>资费名称</th>
	          <th>类型</th>
	          <th>生效日期</th>
	          <th>截止日期</th>
	          <th>状态</th>
	          <th>操作员</th>
	          <th>最后操作时间</th>
	          <th>操作</th>
	        </tr>
	      </thead>
	      
	      <tbody>
	        <tr>
	          <th><input type="checkbox" class="list-checkbox"></th>
	          <td>c01</td>
	          <td>SKKD对个人收费90元、次</td>
	          <td>按次数</td>
	          <td>2017-11-11 12:00</td>
	          <td>2017-11-11 12:00</td>
	          <td class="list-state list-state-0">已暂停</td>
	          <td>李红</td>
	          <td>2017-11-11 12:00</td>
	          <td class="list-action">
	          	<a href="electric/jsp/chargesNew_cg.jsp">查看/修改</a>
	          	<a href="javascript:;" class="list-switch list-switch-on">开启</a>
	          	<a href="javascript:;" class="list-switch list-switch-off" style="display: none;">暂停</a>
	          	<a href="javascript:;" class="delTr">删除</a>
	          </td>
	        </tr>
	        
	         <tr>
	          <th><input type="checkbox" class="list-checkbox"></th>
	          <td>c01</td>
	          <td>SKKD对个人收费90元、次</td>
	          <td>按次数</td>
	          <td>2017-11-11 12:00</td>
	          <td>2017-11-11 12:00</td>
	          <td class="list-state list-state-1">已开启</td>
	          <td>李红</td>
	          <td>2017-11-11 12:00</td>
	          <td class="list-action">
	          	<a href="electric/jsp/chargesNew_cg.jsp">查看/修改</a>
	          	<a href="javascript:;" class="list-switch list-switch-on" style="display: none;">开启</a>
	          	<a href="javascript:;" class="list-switch list-switch-off">暂停</a>
	          	<a href="javascript:;" class="delTr">删除</a>
	          </td>
	        </tr>
	      </tbody>
	    </table>
	    
	    <nav>
		  <ul class="pagination right">
		    <li><a href="javascript:;">首页</a></li>
		    <li class="active"><a href="javascript:;">1</a></li>
		  	<li><a href="javascript:;">2</a></li>
		    <li><a href="javascript:;">3</a></li>
		    <li><a href="javascript:;">4</a></li>
		    <li><a href="javascript:;">5</a></li>
		    <li><a href="javascript:;">尾页</a></li>
		  </ul>
		</nav>
	</div>
	
	<script type="text/javascript">
		$(document).ready(function(){
			listSwitch();//批量开启、批量暂停、单独开启、单独暂停
			delEvent();//删除当前一行、批量删除
		});
		
		function listSwitch(){
			//批量开启
			$(".startAll").on("click",function(){
				var trChecked=$(".list-checkbox:checked").parents("tr");
				if( listTrCount() != 0){//判断是否没有选中行
					trChecked.find(".list-state").text("已开启").css("color","#34D63A");
					trChecked.find(".list-switch-on").css("display","none");
					trChecked.find(".list-switch-off").css("display","inline-block");
				}
				
			});
			//批量暂停
			$(".stopAll").on("click",function(){
				var trChecked=$(".list-checkbox:checked").parents("tr");
				if( listTrCount() != 0){//判断是否没有选中行
					trChecked.find(".list-state").text("已暂停").css("color","red");
					trChecked.find(".list-switch-off").css("display","none");
					trChecked.find(".list-switch-on").css("display","inline-block");
				}
				
			});
			
			//单独开启
			$(".list-switch-on").on("click",function(){
				var thisItem=$(this);
				thisItem.css("display","none");
				thisItem.siblings(".list-switch").css("display","inline-block");
				thisItem.parents("tr").find(".list-state").text("已开启").css("color","#34D63A");
			});
			//单独暂停
			$(".list-switch-off").on("click",function(){
				var thisItem=$(this);
				thisItem.css("display","none");
				thisItem.siblings(".list-switch").css("display","inline-block");
				thisItem.parents("tr").find(".list-state").text("已暂停").css("color","red");
			});
			
		}
		
		function delEvent(){
			//删除框的确定事件
			$(".delSureBtn").on("click",function(){
				var thisBtn=$(this);
				$(".delFlag").css("display","none");//删除设有删除标记的行
				$(".newAlertBox").remove();
			});
			//删除框的取消事件
			$(".delOffBtn").on("click",function(){
				$(".list-table tr").removeClass("delFlag");//当删除框取消时，全部删除标记消失
			});
		}
		
	</script>
  </body>
</html>

